from config import HOST


class Topup:
    def __init__(self, session):
        """获取session"""
        self.session = session
        """认证成功"""
        self.__url_AuthenticationOk = HOST + "/member/realname/approverealname "
        """查询认证状态"""
        self.__url_select_AuthenticationOk = HOST + "/member/member/getapprove"
        """开户"""
        self.__url_open_register = HOST + "/trust/trust/register"
        """图片验证码"""
        self.__url_img_code = HOST + "//common/public/verifycode/{}"
        """充值"""
        self.__url_recharge = HOST + "/trust/trust/recharge"

    """认证接口封装"""

    def AuthenticationOk(self):
        data = {
            "realname": "华仔",
            "card_id": "220102200806078030"
        }
        return self.session.post(url=self.__url_AuthenticationOk, data=data, files={"x": "y"})

    """查询认证接口封装"""

    def select_AuthenticationOk(self):
        return self.session.post(url=self.__url_select_AuthenticationOk)

    """开户接口封装"""

    def open_rehister(self):
        return self.session.post(url=self.__url_open_register)

    """图片验证码"""

    def img_code(self, random):
        return self.session.get(url=self.__url_img_code.format(random))

    """充值接口封装"""

    def api_recharge(self, img):
        data = {
            "paymentType": "chinapnrTrust",
            "amount": "10000",
            "formStr": "reForm",
            "valicode": img

        }
        return self.session.post(url=self.__url_recharge, data=data)
